package controller;

import domain.Role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import service.IRoleService;

import javax.annotation.security.RolesAllowed;
import java.util.List;

/**
 * @author ：Yan Guang
 * @date ：Created in 2020/9/25 12:48
 * @description：
 */
@Controller
@RequestMapping("/role")
public class RoleController {

    @Autowired
     private IRoleService roleService;

    @RequestMapping("/findAll.do")
    public ModelAndView findAll() throws Exception {
        ModelAndView mv = new ModelAndView();
        List<Role> roleList = roleService.findAll();
        mv.addObject("roleList",roleList);
        mv.setViewName("role-list");
        return mv;
    }
    @RequestMapping("/save.do")
    public String saveRole(Role role) throws Exception {
        roleService.saveRole(role);
        return "redirect:findAll.do";
    }

}
